<?php
/*
*用於後臺開發者的佈局
*/
/* @var $this \yii\web\View */
/* @var $content string */

use yan\backendclient\assets\AppDebugAsset;
use yii\helpers\Html;
use yan\backendclient\assets\bootstrap\Nav;
use yan\backendclient\assets\bootstrap\NavBar;
use yan\backendclient\assets\bootstrap\Alert;
use yii\widgets\Breadcrumbs;

AppDebugAsset::register($this);
$this->registerJsFile('/backend/web/jquery/dist/jquery.min.js', ['position'=>\yii\web\View::POS_HEAD]);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap">
    <?php
    NavBar::begin([
        'brandLabel' => Yii::t('debug','Backend') . '-' . APP_NAME,
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar-expand-lg navbar-dark bg-dark',
            'target_id'=>'navbarNavHeader'
        ],
    ]);
    
    if (!Yii::$app->user->isGuest) {

        $menuItems[] = ['label' => Yii::t('debug','Authenticate'), 'url' => '#',
                        'items'=>[
                        ['label'=>Yii::t('debug','AuthRole'),'url'=>['/backendclient/role']],
                        ['label'=>Yii::t('debug','AuthRoleItem'),'url'=>['/backendclient/role/item']],
                        ['label'=>Yii::t('debug','AuthRule'),'url'=>['/backendclient/role/rule']],
                        ]];
        
        $menuItems[] = ['label' => Yii::t('debug','Menu'), 'url' => ['/backendclient/default/index'],
                        'items'=>[
                        ['label' => Yii::t('debug','Menu'), 'url' => ['/backendclient/default/index']],
                        ['label' => Yii::t('debug','Layout'), 'url' => ['/layoutroute/default/index']],
                        ]
                        ];
        $menuItems[] = ['label' => Yii::t('debug','Backend Modules'), 'url' => ['/backendclient/module'],
                        'items'=>[
                        ['label'=>Yii::t('debug','Backend Modules'),'url'=>['/backendclient/module']],
                        ]
                        ];

        $menuItems[] = ['label' => Yii::t('debug','Language'), 'url' => ['/backendclient/language'],
                        ];

        $menuItems[] = [
            'label' => Yii::t('debug','Logout').' (' . Yii::$app->user->identity->username . ')',
            'url' => ['/site/logout'],
            'linkOptions' => ['data-method' => 'post']
        ];
    }

    echo Nav::widget([
        'options' => ['class' => 'navbar-nav ml-auto mt-2 mt-lg-0'],
        'items' => $menuItems,
    ]);
    NavBar::end();
    ?>

    <div class="container" style="clear: both; padding-top:0px;">
        <?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ?>
        <?php
            if( Yii::$app->getSession()->hasFlash('message') ) {
                echo Alert::widget([
                    'options' => [
                        'class' => 'alert-success', //这里是提示框的class
                        'fade'=>'300',
                    ],
                    'body' => Yii::$app->getSession()->getFlash('message'), //消息体
                ]);
            }
        ?>

        <?= $content ?>
    </div>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
